package ca.seia.comp6521.a2.itemsetstorage;

import org.github.jamm.MemoryMeter;

import com.javabi.sizeof.MemoryUtil;

public class Pair<T> {

	private T valueOne;
	private T valueTwo;
	
	public Pair(T valueOne, T valueTwo) {
		this.valueOne = valueOne;
		this.valueTwo = valueTwo;
	}

	public T getValueOne() {
		return valueOne;
	}

	public void setValueOne(T valueOne) {
		this.valueOne = valueOne;
	}

	public T getValueTwo() {
		return valueTwo;
	}

	public void setValueTwo(T valueTwo) {
		this.valueTwo = valueTwo;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((valueOne == null) ? 0 : valueOne.hashCode());
		result = prime * result + ((valueTwo == null) ? 0 : valueTwo.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Pair other = (Pair) obj;
		if (valueOne == null) {
			if (other.valueOne != null)
				return false;
		} else if (!valueOne.equals(other.valueOne))
			return false;
		if (valueTwo == null) {
			if (other.valueTwo != null)
				return false;
		} else if (!valueTwo.equals(other.valueTwo))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Pair [valueOne=" + valueOne + ", valueTwo=" + valueTwo + "]";
	}
	
	public static void main(String[] args) throws IllegalAccessException {
		Pair<Integer> p = new Pair<Integer>(1,2);
		Pair<Integer> p2 = new Pair<Integer>(1,2);
		int[] pair = new int[]{1,2};
		char[] charpair = new char[]{1,2};
		CharPair cp = new CharPair('1', '2');
		CharPair cp2 = new CharPair(200,300);
		
		CharPair[] charpairs = new CharPair[2];
		IntPair[] intpairs = new IntPair[2];
		
		Integer x = 2;
		Character c = 'd';
		IntPair p1 = new IntPair(1, 2);
		String st = "1";
		
		MemoryMeter meter = new MemoryMeter();
		System.out.println("size of charArrayPair is " + meter.measureDeep(charpair));
		System.out.println("size of IntArrayPAir  is " + meter.measureDeep(pair));
		System.out.println("size of IntegerPair is " + meter.measureDeep(p));
		System.out.println("size of Char PAir  is " + meter.measureDeep(cp2));
		System.out.println("size of Int PAir  is " + meter.measureDeep(p1));
		System.out.println("Size of Integer is " + meter.measureDeep(x));
		System.out.println("Size of Charaacter is " + meter.measureDeep(c));
		System.out.println("Size of char is" + meter.measureDeep('c'));
		System.out.println("Size of int is" + meter.measureDeep(4));
		System.out.println("Size of boolean is" + meter.measureDeep(false));
		
		Short t = 3;
		System.out.println("Size of boolean is" + meter.measureDeep(t));
		System.out.println("Size of charPairs is" + meter.measureDeep(charpairs));
		System.out.println("Size of intPairs is" + meter.measureDeep(intpairs));
		System.out.println("Size of string is" + meter.measureDeep(st));
		System.out.println("---------------------------------------------");

//		System.out.println("size of IntegerPair is " + meter.measure(p));
//		System.out.println("size of Char PAir  is " + meter.measure(cp));
//		System.out.println("size of Int PAir  is " + meter.measure(cp));
//		System.out.println("Size of Integer is " + meter.measure(x));
//		System.out.println("Size of Charaacter is " + meter.measure(c));
//		System.out.println("Size of char is" + meter.measure('c'));
//		System.out.println("Size of int is" + meter.measure(4));
		
		
		System.out.println("size of charArrayPair is " + MemoryUtil.sizeOf(charpair));
		System.out.println("size of IntArrayPAir  is " + MemoryUtil.sizeOf(pair));
		System.out.println("size of IntegerPair is " + MemoryUtil.sizeOf(p));
		System.out.println("size of Char PAir  is " +  MemoryUtil.sizeOf(cp2));
		System.out.println("size of Int PAir  is " +  MemoryUtil.sizeOf(p1));
		System.out.println("Size of Integer is " +  MemoryUtil.sizeOf(x));
		System.out.println("Size of Charaacter is " +  MemoryUtil.sizeOf(c));
		System.out.println("Size of char is" +  MemoryUtil.sizeOf('c'));
		System.out.println("Size of int is" +  MemoryUtil.sizeOf(4));
		System.out.println("Size of charPairs is" + MemoryUtil.sizeOf(charpairs));
		System.out.println("Size of intPairs is" + MemoryUtil.sizeOf(intpairs));
		System.out.println("Size of string is" + MemoryUtil.sizeOf(st));
		
		
		System.out.println(p.equals(p2));
		System.out.println(p);
		System.out.println(p2);
	}
	
}
